﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<VMAdminViewOrder>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Index
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MoreLinks" runat="server"> 
    <% Html.RenderAction("Menu","CarView"); %>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
    <p>
        <%: TempData["msg"] %></p>
    <% if (Model != null)
       { %>
        <fieldset class="fieldset_style">
    <legend class="legend_title"><div>All Orders</div></legend>
        <% Html.Grid<AdminViewInOrder>(Model.Orders)
           .Columns(builder =>
           {
              // builder.For(x => x.OrderId);
             //  builder.For(x => x.BrandId);
             //  builder.For(x => x.TypeId);
               builder.For(x => x.Count);
               builder.For(x => x.BorrowDate.ToString("yyyy-MM-dd")).Named("date");
               builder.For(x => x.SendDate);
               builder.For(x => x.UserName);
               builder.For(x => x.Price);
               builder.For(x => x.State);
               builder.For("acting").Named("test")
                   .Action(p =>
                   { %>
                   <td>
                      <%switch (p.State)
                     {
                          case 0:
                  %>
                             <%: Html.ActionLink("Edit", "Edit", new { id = p.OrderId })%>
                             <%: Html.ActionLink("Pay", "pay", new { id = p.OrderId })%>
                              <%: Html.ActionLink("Cancel", "cancel", new { id = p.OrderId })%>
                  <%         break;
                          case 1:
                  %>
                             <%: Html.ActionLink("Return", "Return", new { id = p.OrderId })%>
                  <%         break;
                          default:
                             break;
                    } %>
                    </td>
                   <%});
           })
           .Attributes(new Hash(@class => "carmanage", cellspacing => "0")).Render();%>
           
               <%= Html.Pager(Model.Orders) %>
</fieldset>

  <%--  <table>
        <tr>
            <td>OrderId</td>
            <td>BrandId</td>
            <td>TypeId</td>
            <td>Count</td>
            <td>BorrowDate</td>
            <td>SendDate</td>
            <td>UserName</td>
            <td>Price</td>
            <td>State</td>
            <td>acting</td>
        </tr>
        
        <%foreach (var item in Model.Orders)
          { %>
          <tr id="1">
            <td><%:item.OrderId%></td>
            <td><%:item.BrandId%></td>
            <td><%:item.TypeId %></td>
            <td><%:item.Count %></td>
            <td><%:item.BorrowDate%></td>
            <td><%:item.SendDate%></td>
            <td><%:item.UserName%></td>
              <td>
                  <%:item.Price %>
              </td>
              <td>
                  <%:item.State %>
              </td>
              <td>
                  <% int State = item.State;
                     switch (State)
                     {
                          case 0:
                  %>
                             <%: Html.ActionLink("Edit", "Edit", new { id = item.OrderId })%>
                             <%: Html.ActionLink("Pay", "pay", new { id = item.OrderId })%>
                  <%         break;
                          case 1:
                  %>
                             <%: Html.ActionLink("Return", "Return", new { id = item.OrderId })%>
                  <%         break;
                          default:
                             break;
                    } %>
              </td>
          </tr>
        <%} %>
    </table>--%>
    <% } %>
</asp:Content>
